import "./style.scss";
import "../../comm.scss";
import React,{ Component } from 'react';
import Cesium from "cesium/Cesium";
import { Button } from 'antd';
import { connect } from "react-redux";

class Point extends Component {

    addPoint () {
        const { viewer } = this.props;
        viewer.entities.add({
            position : Cesium.Cartesian3.fromDegrees(- 75.59777,40.03883),
            point : {
                pixelSize : 10,
                color : Cesium.Color.YELLOW
            }
        });
        viewer.flyTo(viewer.entities);
    }

    removePoint () {
        const { viewer } = this.props;
        viewer.entities.removeAll();
    }

    render () {
        return (
            <div className="btn">
                <Button onClick={ this.addPoint.bind(this) }>添加点</Button>
                <Button onClick={ this.removePoint.bind(this) }>移除点</Button>
            </div>
        );
    }
}

const mapStateToProps = state => ({
    viewer : state.App.viewer
});

export default connect(mapStateToProps,{})(Point);